package com.liyy.platform.other.mytest;

import java.sql.*;
public class JDBC
{
	public static void main(String [] args){
		Connection conn=null;
		PreparedStatement pstmt=null;
		ResultSet rs=null;
	 try {
		Class.forName("oracle.jdbc.driver.OracleDriver");
		conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","xxlims","xxlims") ;
		pstmt=conn.prepareStatement("select * from userinfo u where u.userid=?");
		pstmt.setString(1, "66");
		rs=pstmt.executeQuery();
		while(rs.next()){
			System.out.println(rs.getString("realname"));
		}
	 
	 } catch (ClassNotFoundException e) {
		e.printStackTrace();
	} catch (SQLException e) {
		e.printStackTrace();
	}finally{
	try {
		if(rs!=null){
			rs.close();
			rs=null;
		}
		if(pstmt!=null){
			pstmt.close();
			pstmt=null;
		}		
		if(conn!=null){
			conn.close();
			conn=null;
		}
	} catch (SQLException e) {
		e.printStackTrace();
	}

}
}
}